package com.ynt.pay.mock.controller;

import com.ynt.pay.mock.service.TraceIdService;
import com.ynt.pay.user.api.dto.UserListDto;
import com.ynt.pay.user.api.rest.UserRemoteClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.toolkit.trace.TraceContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping("/mock")
@Slf4j
public class UserController {

    @Autowired
    UserRemoteClient userRemoteClient;
    @Autowired
    TraceIdService traceIdService;

    @GetMapping("/list")
    public List<UserListDto> list() {

        String traceId = TraceContext.traceId();
        log.info("traceId===>{}", traceId);

        traceIdService.testTranceAnnotation();
        return userRemoteClient.list();
    }

    @GetMapping("/hello")
    public String hello() {
        return userRemoteClient.hello();
    }
}
